package com.ls.fw.web.core.http.bean;


public enum ContentType{
	stream("*","application/octet-stream")
	,bmp("bmp","application/x-bmp")
	,gif("gif","image/gif")
	,ico("ico","image/x-icon")
	,java("java","java/*")
	,jpeg("jpeg","image/jpeg")
	,jpg("jpg","application/x-jpg")
	,jsp("jsp","text/html")
	,html("html","text/html")
	,txt("txt","text/plain")
	,pdf("pdf","application/pdf")
	,xls("xls","application/vnd.ms-excel")
	,xlsx("xlsx","application/vnd.ms-excel")
	,doc("doc","application/msword")
	,docx("docx","application/msword")
	,zip("docx","application/zip")
	;
	
	private String ext = "*";
	private String type = "application/octet-stream";
	
	private ContentType(String ext){
		this.ext = ext;
	}
	
	private ContentType(String ext,String type){
		this.ext = ext;
		this.type = type;
	}

	public String getExt() {
		return ext;
	}
	
	public static ContentType value(String ext) {
		// 所有的枚举值
		ContentType[] season = values();
		// 遍历查找
		for (ContentType s : season) {
			if (s.getExt().equalsIgnoreCase(ext)
				|| ("."+s.getExt()).equalsIgnoreCase(ext)) {
				return s;
			}
		}
		return null;
	}
	
	public static boolean contains(String ext) {
		// 所有的枚举值
		ContentType[] season = values();
		// 遍历查找
		for (ContentType s : season) {
			if (s.getExt().equalsIgnoreCase(ext) 
				|| ("."+s.getExt()).equalsIgnoreCase(ext)) {
				return true;
			}
		}
		return false;
	}

	public String getType() {
		return type;
	}
 
}
